<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="ThemeBucket">
    <link rel="shortcut icon" href="#" type="image/png">

    <title>Form Layouts</title>
    <!--file upload-->
    <link rel="stylesheet" type="text/css" href="/public/css/bootstrap-fileupload.min.css" />

    <link href="/public/js/iCheck/skins/flat/green.css" rel="stylesheet">

    <?php $this->load->view('library/header');?>
</head>
<style>
	.buxing{
		border-top-left-radius:7px;border-top-right-radius:7px;border-bottom-left-radius:7px;border-bottom-right-radius:7px;
	}
</style>
<body class="sticky-header">
<section>
    <?php $this->load->view('library/left');?>
    <div class="main-content" >
        <?php $this->load->view('library/top');?>
        <div class="page-heading">
            <h3>
                商品加色列表
            </h3>
            <ul class="breadcrumb">
                <li>
                    <a href="#">Forms</a>
                </li>
                <li class="active"> Forms Layouts </li>
            </ul>
        </div>

        <section class="wrapper">
            <div class="row">
                <div class="col-lg-12">
                    <section class="panel">
                        <div class="panel-body">
                            <form class="cmxform form-horizontal adminex-form" id="commentForm" enctype="multipart/form-data" method="post" action="">

								<div style="width: 461px; float: left;margin-left: 10%;">
									<?php foreach ($post_sku['color'] as $ali_k => $ali_v) :?>
										<div style="margin-top: 5px;">
											<div class="col-lg-6">
												<input style="" value="<?php echo $ali_v['ali_value']?>" name="aliyun_sku[ali_color][]" readonly = "readonly" class="form-control ">
											</div>
											<div class="col-lg-6">
												<select name="aliyun_sku[color][]" class="option-color form-control ">
													<option value="">选择颜色</option>
													<?php foreach ($color as $k => $v) :?>
														<option <?php if($v['color_en'] == $ali_v['value']){echo "selected='selected'";}?> value="<?php echo $v['color_en']?>"><?php echo $v['color_en'];?> (<?php echo $v['color_zh'];?>)</option>
													<?php endforeach;?>
												</select>
											</div>
										</div>
									<?php endforeach;?>
								</div>
								<div style="width: 461px; float: right;margin-right: 30%;">
									<?php foreach ($post_sku['size'] as $ali_k => $ali_v) :?>
										<div style="margin-top: 5px;">
										<div class="col-lg-6" >
											<input style="" value="<?php echo $ali_v['ali_value']?>" name="aliyun_sku[ali_size][]" readonly = "readonly" class="form-control ">
										</div>
										<div class="col-lg-6">
											<select name="aliyun_sku[size][]" class="option-size form-control ">
												<option value="">选择颜色</option>
												<?php foreach ($size as $k => $v) :?>
													<option <?php if($v['size_value'] == $ali_v['value']){echo "selected='selected'";}?> value="<?php echo $v['size_value'];?>"><?php echo $v['size_value'];?> (<?php echo $v['size_code'];?>)</option>
												<?php endforeach;?>
											</select>
										</div>
										</div>
									<?php endforeach;?>
								</div>
                                <div class="form-group">
                                    <label class="col-lg-2 col-sm-2 control-label"></label>
                                    <div class="col-lg-10" style=" margin-left: 40%;margin-top: 50px;">
                                        <button type="submit" class="btn btn-primary" style="float: left;">提交</button>
                                        <!-- <div  class="cli_add_sku" style="margin-left: 26%;border-top-left-radius:7px;border-top-right-radius:7px;border-bottom-left-radius:7px;border-bottom-right-radius:7px;background-color: #424F63;width: 65px;color: #ffff"><span style="margin-left: 7px">添加sku</span></div> -->
                                    </div>
                                </div>
                            </form>
                        </div>
                    </section>
                </div>
            </div>
        </section>
        <footer>
            2014 &copy; AdminEx by
        </footer>
    </div>

</section>
<!-- <div class="add_cku" style="display: none;">
	<div class="col-lg-6" style="margin-left: 25%">
	<div class="col-lg-5">
		<select name="color" style="float: left; width: 200px;margin-top: 5%;" class="option-color form-control sunjian_color supp_sku_color">
			<option value="">选择颜色</option>
			<?php foreach ($color as $color_k => $color_v) :?>
				<option value="<?php echo $color_v['color_en'];?>"><?php echo $color_v['color_en'],'('.$color_v['color_zh'].')';?></option><?php endforeach;?>
		</select>
	</div>
	<div class="col-lg-5">
		<select name="size" style="margin-top: 5%;" class="option-color form-control sunjian_color supp_sku_color">
			<option value="">选择尺寸</option>
			<?php foreach ($size as $size_k => $size_v) :?>
				<option value="<?php echo $size_v['size_value'];?>" ><?php echo $size_v['size_value'],'('.$size_v['size_code'].')';?></option>
			<?php endforeach;?>
		</select>
	</div>
	<div style="margin-top: 20px;background-color: #424F63;width: 30px;float: left;color: #ffff;" class="buxing">
		<span style="margin-left: 10px;">--</span>
	</div>
	</div>
</div> -->
<?php $this->load->view('library/footer');?>
<script src="/public/js/iCheck/jquery.icheck.js"></script>
<script src="/public/js/icheck-init.js"></script>
<script type="text/javascript" src="/public/js/bootstrap-fileupload.min.js"></script>
<script type="text/javascript">

    $(function () {
    	// $('.cli_add_sku').click(function(){
    	// 	var add_cku = $('.add_cku').html();
    	// 	$('.show_sku').append(add_cku);
    	// })
    	// $(document).on('click','.buxing',function(){
    	// 	$(this).parent().remove();
    	// })

        $('#commentForm').submit(function () {
            $('button[type="submit"]').attr('disabled','disabled').addClass('btn-submit-disabled').html('正在提交，请稍等...');

            var data = new FormData(this);
            $.ajax({
                url: '<?php echo base_url("PrepareGoods/index_add_color/prepare_id/{$prepare_id}");?>',
                type: 'POST',
                cache: false,
                dataType:'json',
                data: data,
                success: function(data) {
                    if (data.status != 'success') {
                        swal({
                            title:   data.info,
                            text: '2秒后关闭',
                            type: data.status,
                            allowOutsideClick: false,
                            timer: 1500,
                            showConfirmButton: false
                        });
                    } else {
                        swal({
                            title: data.info,
                            text: '2秒后关闭',
                            type: data.status,
                            allowOutsideClick: false,
                            timer: 1500,
                            showConfirmButton: false
                        }).then(function(isConfirm) {
                            window.onbeforeunload = '';
                            window.location.href = '<?php echo base_url('PrepareGoods/index_accurate?prepare_state=5');?>';
                        });
                    }
                    $('button[type="submit"]').attr("disabled",false).removeClass('btn-submit-disabled').html('提交信息');
                },
                processData: false,
                contentType: false
            });
            setTimeout(function() {
                $('button[type="submit"]').attr("disabled",false).removeClass('btn-submit-disabled').html('提交');
            }, '3000');
            return false;
        });

        // $('.get-goods').on('click', function () {

        //     var supp = $(this).parents('.addsupp').find('.curl').val();

        //     thisg = $(this);

        //     $(this).html('获取中...');
        //     var supp_id = $('.selectpicker').val();
        //     $.post("<?php echo base_url('PrepareGoods/ajax_ali_goods');?>", {ali_url: supp,supp_id:supp_id}, function (aliData) {

        //         var result_color = '', result_size = '';
        //         var data = aliData.data;

        //         thisg.parents('.addsupp').find('.supp_sn').val(data.ali_sn);
        //         thisg.parents('.addsupp').find('.in_price').val(data.ali_price);
        //         thisg.parents('.addsupp').find('.g_supp_id').val(data.g_supp_id);

        //         $('.supp_name').val(data.title);

        //         if (data.skuProps) {
        //             for (var x in data.skuProps) {

        //                 var obj = {
        //                     items: data.skuProps[x].value
        //                 };

        //                 if (data.skuProps[x].prop === '颜色') {
        //                     result_color += template('color_temp', obj);
        //                 } else if (data.skuProps[x].prop === '尺码') {
        //                     result_size += template('size_temp', obj);
        //                 }
        //             }
        //             $('.supp_sku .sku_color').html(result_color);
        //             $('.supp_sku .sku_size').html(result_size);
        //             $('.flat-green input').iCheck({
        //                 checkboxClass: 'icheckbox_flat-green',
        //                 radioClass: 'iradio_flat-green'
        //             });
        //         }


        //     }, 'json');
        // });



    });

</script>

<!--common scripts for all pages-->
<script src="/public/js/scripts.js"></script>

</body>
</html>
